<template>
    <div>
        <Row class="margin-top-10 searchable-table-con1">
                <Table refs="formTemplate" border :columns="columns" :data="records"></Table>
        </Row>
        <Row class="margin-top-10 searchable-table-con1">
            <Page :total="totalCount" :page-size="size" show-total @on-change="changePage"></Page>
        </Row>
    </div>
</template>

<script>
    import api from "../../../../../../libs/api"
    export default {
    name: 'TableRender',
    props: {
        obj: {
            type: Object,
            default () {
                return {};
            }
        }
    },
    data () {
        return {
            columns: [],
            records:[],  //表单列表
            totalCount:0,//表单列表总页数
            current: 1,//当前页
            size: 10,//页面大小
            totalPage: 0, //总条数
        };
    },
    created () {
        this.init();
    },
    methods: {
        init () {
            let data = {};
            data.current = this.current;
            data.size = this.size;
            this.$get(api.resources.base+"/"+this.obj.dictionaryKey,{}).then(response=>{
                if(200==response.code&&response.obj){
                    this.$get(api.baseURL+response.obj.url).then(response=>{
                        if(response.obj){
                            this.totalPage = this.util.calTotalPage(response.obj.page.total, this.size);
                            this.totalCount = response.obj.page.total;
                            this.columns=response.obj.columns;
                            this.records=response.obj.page.records;
                        }
                    });
                }
            });
        },
        changePage(index){
            this.current = index;
            this.handleRead();
        }
    }
};
</script>
